﻿import QtQuick 2.0
import QtQuick.Window 2.12
import QtQuick.Controls 2.12
import "../components"
import "../chromatogram"

ApplicationWindow {

    id: root

    title: "能谱图"

    height: 800*dp
    width: 1000*dp
    minimumWidth: 600*dp
    minimumHeight: 400*dp


    Connections{
        target: mainwindow
        onSigExportReportWithChrom: {
            root.show()
            console.log("调用能谱图的导出报告-保存图片")
            chromatogram.initRange()
            chromatogram.grabToImage(function(result){
                result.saveToFile("tmpChromImage.png")
                CReport.exportReport_auto()          // 导出报告(自动导出的那一份)
                root.hide()
            })
        }
    }


    onVisibleChanged: {
        height = 800*dp; width = 1000*dp
        if(visible){
            root.x = mainwindow.x + mainwindow.width - width
            root.y = mainwindow.y + mainwindow.height - height
            chromatogram.refreshChartData()
        }
    }
    onHeightChanged: {
        chromatogram.height = height
        chromatogram.width = width
    }onWidthChanged: {
        chromatogram.height = height
        chromatogram.width = width
    }

    Chromatogram{
        id: chromatogram
        height: parent.height
        width: parent.width
        showDetails: 1
        onHeightChanged: {
//            console.log("能谱图的height改变", height)
        }
    }
//    Text{       // 为啥我要塞到这里呢？算了就塞到这儿吧
//        x: 20*dp; y: 20*dp
//        text: "能谱图"
//        font.pixelSize: config.fontsize_1
//        font.bold: true
//    }
    Text{
        x: 100*dp; y: 20*dp
        text: "当前能谱检测为手动模式，能谱信号达到要求后请点击[继续]，收集产物"
        visible: gExpIsPause === 1 && gStateExp.expPauseType === 1
        font.pixelSize: config.fontsize_1
        color: "#AAA"

    }

}
